package stateAAs.fusions 
{
	import flash.sampler.getSize;
	import org.agony2d.gpu.AAFacade;
	import org.agony2d.gpu.BatchGroupAA;
	import org.agony2d.gpu.core.ImageAA;
	import org.agony2d.gpu.TingedImageAA;
	import org.agony2d.input.KeyboardManager;
	
	import org.agony2d.Agony;
	import org.agony2d.gpu.AloneGroupAA;
	import org.agony2d.gpu.StateAA;
	import org.agony2d.notify.AEvent;

public class Batch_StateAA extends StateAA {
	
	/** overwritable... */
	override public function get smoothing() : Boolean {
		return true
	}
	
	/** overwritable... */
	override public function get tinted() : Boolean {
		return true
	}
	
	/** overwrite... */
	override public function get fullTex() : String {
		return "A_32"
	}
	
	/** overwrite... */
	override public function enter() : void {
		var image:ImageAA
		var i:int
		
		mBatchGroup = new BatchGroupAA("A_32", "true", "true")
		this.group.addNode(mBatchGroup)
		
		mLength = this.stateArgs[0]
		while (i < mLength) {
			mImgList[i++] = this.createImg()
		}
		
		Agony.addEventListener(AEvent.ENTER_FRAME, update)
		KeyboardManager.getInstance().getState().press.addEventListener("B", function(e:AEvent):void {
			mBatchGroup.reset()
		})
	}
	
	override public function exit() : void {
		
	}
	
	
	private var mImgList:Array = []
	private var mLength:int
	private var mBatchGroup:BatchGroupAA
	
	
	private function createImg(): TingedImageAA {
		//var image:ImageAA
		var image:TingedImageAA
		
		//image = new ImageAA
		image = new TingedImageAA
		image.textureData = FULL_TEX
		image.x = 60 + Math.random() * 250
		image.y = 60 + Math.random() * 520
		image.pivotX = 16
		image.pivotY = 16
		//image.pivotX = 32
		//image.pivotY = 32
		image.rotation = Math.random() * 180
		image.color = 0xFFFFFF * Math.random()
		image.alpha = Math.random() * 0.75 + 0.25
		mBatchGroup.addNode(image)
		return image
	}
	
	private function update(e:AEvent):void {
		//var image:ImageAA
		var image:TingedImageAA
		var i:int
		
		while (i < mLength) {
			image = mImgList[i++];
			image.rotation += 1
		}
		
		//mBatchGroup.reset()
	}
}

}